var currentPage=1;
//列表
loadMyEssay();

function loadMyEssay() {
	$(document).ready(function() {
		init(currentPage);
	});

	function init(pageNo) {
		
		$("#brandList").html("");
		$.ajax({
			url: urlcore + "/api/brand/selectListPage?current=" + pageNo,
			type: "get",
			dataType: 'json',
			async: false,
			contentType: "application/json;charset=utf-8",
			success: function(data) {
				if(data.success == true) {
					$.each(data.data.list, function(i, n) {
						
						var brandImg=n.brandImg==null?'http://app.jiagangwangluo.com/api//ATTACHMENT/cab06117-6607-401a-843d-5ac103323fb6/default.png':n.brandImg;
						var title=n.title==null?"暂无":n.title;
						var thislist =
							'<dl>'+
						'<a href="10.0.0dianpu.html?shopId='+n.shopId+'">'+
							'<dt>'+
	    				'<img class="brandImg123" src="'+brandImg+'" />'+
	    			'</dt>'+
							'<dd>'+title+'</dd>'+
						'</a>'+
					'</dl>';
						$('#brandList').append(thislist);
					});
					
					
					 //固定宽高
					$(function(){
						var imgList1 = document.getElementsByClassName("brandImg123");  
					    var w=148;
					    var h=148;
					    for(var i=0;i<imgList1.length;i++){
					        if(imgList1[i].width>w || imgList1[i].height>h){  
					            imgList1[i].width = w;  
					            imgList1[i].heigth = h;  
					        }  
					    }  
					})

					$("#pager").pager({
						pagenumber: pageNo,
						pagecount: data.data.pages,
						totalcount: data.data.total,
						buttonClickCallback: PageClick
					});

				} else if(data.code == 'OVERTIME') {
					var thisUrl = window.location.href;
					//alert(thisUrl);
					if(thisUrl.indexOf('1.0.0denglu.html') <= -1) {
						top.window.location.href = "1.0.0denglu.html";
					}

				} else {
					if(data.msg != '空数据') {
						layer.alert(data.msg)
					} else {
						$('#thiscount').text(0);
					}
				}

			},
			error: function() {
				layer.alert("error");
			}
		});
	}
	PageClick = function(pageclickednumber) {
		init(pageclickednumber);
	}
}

